<%@ page import="javax.sql.*"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html:html>
	<head>
		<html:base />
		<link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/>

		<title><bean:message key="admin.title" /></title>
	</head>

	<body>
		<p class="sansserif">
		<div class="container">
		<div class="center_div">
			<!-- in case validation of the entry data fails in the data bean -->
			<html:errors />
			
			<table>
			<tr>
				<td><b><bean:message key="admin.name.title" /></b></td>
				<td></td><td></td><td></td>
				<td><a href="../invalidate.jsp">Logout</a></td>
			</tr>
			<tr>
			</tr>
			</table>
			
			<br><br>
			<html:link action="/startReviewing">Start review process</html:link>
			<br><br>
			<br>
			<p>Add Reviewers as necessary: </p>
			<html:form action="/addReviewer">
				<table>
					<tr>
						<td>Username: </td>
						<td><html:text property="username" size="15" /></td>
					</tr>
					<tr>
						<td>Password: </td>
						<td><html:password property="password" size="15" /></td>
					</tr>
					<tr>
						<td></td>
						<td><html:submit value="Submit" /></td>
					</tr>
				</table>
			</html:form>
			<br>

			<table>
			<tr>
				<th>Username</th>
				<th>Action</th>
			</tr>
			
			<%-- -------- Iteration Code -------- --%>
			<%
				// Get the studentsRowSet
				RowSet reviewerSet = (RowSet) request.getAttribute("reviewerSet");
		
				// Iterate over the RowSet
			if(reviewerSet != null)
			{	
				while (reviewerSet.next()) {
			%>
				<%-- Get the first name --%>
				<tr>
				<td>
					<%=reviewerSet.getString(1)%>
				</td>

				<%-- Add a button to delete each reviewer --%>
				<html:form action="/deleteReviewer">
					<html:hidden property="name" value="<%=reviewerSet.getString(\"user_name\")%>" />
					<td><html:submit value="Delete" /></td>
				</html:form>
				</tr>		
			<%
				}
			}
			else 
			{
			%>
				<tr><td>Load all reviewers <b>failed</b>!</td></tr>
			<% 
			}
			%>
			
			</table>
			
		</div>
		</div>
	</body>
</html:html>